package com.example.springboot.config.tomcat;

import org.apache.coyote.ProtocolHandler;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.boot.web.embedded.tomcat.TomcatProtocolHandlerCustomizer;



/**
 * @Author:ChenZhangKun
 * @Date: 2022/9/9 13:52
 */
public class MyTomcatProtocolHandlerCustomizer implements TomcatProtocolHandlerCustomizer<ProtocolHandler> {
    private final ThreadPoolExecutor threadPoolExecutor;

    @Override
    public void customize(ProtocolHandler protocolHandler) {
        System.out.println("自定义tomcat线程池调用了");
        protocolHandler.setExecutor(threadPoolExecutor);
    }

    public MyTomcatProtocolHandlerCustomizer(ThreadPoolExecutor threadPoolExecutor) {
        this.threadPoolExecutor = threadPoolExecutor;
    }

    public ThreadPoolExecutor getThreadPoolExecutor() {
        return threadPoolExecutor;
    }
}
